<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<%--<link rel="stylesheet" href="${pageContext.request.contextPath}/lib/jquery.nyroModal/styles/nyroModal.css"
      type="text/css" media="screen"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript"
        src="${pageContext.request.contextPath}/lib/jquery.nyroModal/js/jquery.nyroModal.custom.js"></script>--%>


<script src="${pageContext.request.contextPath}/js/validateLand.js" type="text/javascript"></script>

<%--<script type="text/javascript">
    $(function() {
        $('.nyroModal').nyroModal();
    });
</script>--%>

<script type="text/javascript">

    $(document).ready(function () {
        validateLandDetails();
    });

    function validateReject() {
        $("#gov-land-init-info-form").validate({
            rules:{
                approvalNote:{
                    required: true
                }
            },
            messages:{
                approvalNote:{
                    required: "Please enter a comment"
                }
            }
        });
    }

    function searchLands() {

        var url = '${pageContext.request.contextPath}' + '/searchLandsSubDivide.do';

        myWindow = window.open(url, '', 'width=980,height=500,scrollbars=yes');
        myWindow.focus();
    }

    function searchLands() {

        //var url = $('#url').val();
        //var test=$('#baseURL').val()+'/searchDefineAmLandsToLandAttach.do';
        var url='${pageContext.request.contextPath}' +'/searchDefineAmLandsToLandAttach.do';

        myWindow = window.open(url, '', 'width=980,height=500,scrollbars=yes');
        myWindow.focus();
    }

</script>

<div id="land-registration-module-home-title" class="module-home-title">
    <s:a href="landRegistrationModule.do">
        <span><img src="${pageContext.request.contextPath}/images/land-reg.png" alt="Land Registration">
            <s:label value="%{getText('land_registration.label')}"/></span>
    </s:a>
    <span class="module-title-breaker"> > </span>
    <s:if test="land.approvalState.ordinal() == 2 && user.role.id == \"ORDS\"">
        <s:a href="approveLandList.do">
        <span><img src="${pageContext.request.contextPath}/images/accept.png" alt="Approve Land Information">
        <s:label value="%{getText('approve_land_info.label')}"/></span>
        </s:a>
    </s:if>
    <s:else>
        <s:if test="land.mode.ordinal() == 1">
            <s:a href="detailForm.do">
        <span><img src="${pageContext.request.contextPath}/images/registration-form.png"
                   alt="Enter Detailed Land Information">
        <s:label value="%{getText('enter_detail_land_info.label')}"/></span>
            </s:a>
        </s:if>
        <s:else>
            <s:a href="initForm.do">
        <span><img src="${pageContext.request.contextPath}/images/init-form.png" alt="Enter Initial Land Information">
            <s:label value="%{getText('enter_initial_land_info.label')}"/></span>
            </s:a>
        </s:else>
    </s:else>
    <div id="back-button" align="right">
        <s:submit type="input" value="%{getText('back.label')}" onclick="goBack();"/>
    </div>
</div>
<div id="init-land-outer" class="form-outer">
    <s:if test="hasActionErrors()">
        <s:div id="message-box" class="message-box">
            <div class="action-err">
                <s:label value="%{getText('error_occurred.label')}"/>
                <s:actionerror/>
            </div>
        </s:div>
    </s:if>
    <s:if test="hasActionMessages()">
        <s:div id="message-box" class="message-box">
            <div class="action-msg">
                <s:actionmessage/>
            </div>
        </s:div>
    </s:if>
    <div id="messageBox"></div>

    <s:if test="subDivideMode==1">
        <h2><s:label value="%{getText('sub_divide_land_edit.label')}"/></h2>
    </s:if>
    <s:else>
        <h2><s:label value="%{getText('sub_divide_land.label')}"/></h2>
    </s:else>
    <fieldset>
        <table>
            <tr>
                <td><input type="button" id="show_landList" value="Search Lands"
                           onclick="searchLands()"/></td>
            </tr>
        </table>

        <s:form action="populateInitLandSubDivideApplication.do" method="POST"
                id="sub-divide-land-form">

            <table>
                <tr>
                    <td><s:label value="%{getText('slmsSerialNumber.label')}"/></td>
                    <td><s:textfield name="slimsSerialNumber"/></td>
                    <td><s:submit/></td>
                    <s:hidden name="landId"/>
                    <s:hidden name="subDivideMode"/>
                </tr>
            </table>

        </s:form>


    </fieldset>

    <s:form method="POST" id="gov-land-init-info-form" name="init-land-info" enctype="multipart/form-data"
            onsubmit="javascript:return validateFormForInputDataSyntaxErrors('gov-land-init-info-form')">
        <s:if test="land.approvalState.ordinal() == 2 && user.role.id == \"ORDS\"">
            <h2><s:label value="%{getText('approve_land_info.label')}"/></h2>
        </s:if>
        <s:else>
            <h2><s:label value="%{getText('sub_divide_land_info.label')}"/></h2>
        </s:else>

        <fieldset>
            <table class="width-100">
                <tr>
                    <td><s:label value="%{getText('parentSerialNumber.label')}"/></td>
                    <td colspan="3">
                        <s:if test="parentLandRefNumber != 0">
                            <s:textfield name="parentLandRefNumber" onKeyPress="return numbersonly(event,true)"
                                         id="parentLandRefNumber"
                                         cssClass="width-200-px" readonly="true"/>
                        </s:if>
                        <s:else>

                            <s:textfield name="parentLandRefNumber" onKeyPress="return numbersonly(event,true)"
                                         id="parentLandRefNumber"
                                         cssClass="width-200-px" value="%{land.parentLand.id}" readonly="true"/>
                        </s:else>

                    </td>
                </tr>
            </table>
        </fieldset>

        <s:include value="./landDetails.jsp"/>

        <%--<s:include value="./landAlienationInfomation.jsp"/>--%>

        <s:if test="land.approvalState.ordinal() == 2 && user.role.id == \"ORDS\"">
            <table class="width-100">
                <tr>
                    <td><s:label value="%{getText('comments.label')}"/></td>
                    <td colspan="3"><s:textarea name="land.approvalNote" cssClass="width-595-px"/></td>
                </tr>
            </table>
        </s:if>
        <s:elseif test="land.approvalNote != null && land.approvalNote.length() > 0">
            <table class="width-100">
                <tr>
                    <td><s:label value="%{getText('comments.label')}"/></td>
                    <td colspan="3">
                        <s:textarea id="approvalNote" readonly="true" name="land.approvalNote" cssClass="width-595-px"/>
                    </td>
                </tr>
            </table>
        </s:elseif>
        <div class="form-button-div right-align">
            <s:if test="land.approvalState.ordinal() == 2 && user.role.id == \"ORDS\"">
                <s:submit value="%{getText('reject.label')}" action="rejectLandInformation"/>
                <s:submit value="%{getText('approve.label')}" action="approveLandInformation"/>
            </s:if>
            <s:elseif test="land.approvalState.ordinal() == 2 || land.approvalState.ordinal() == 0">

                <s:submit action="editSubDividedLandInformation" value="%{getText('edit.label')}"
                          onclick="validateFields()"/>

            </s:elseif>
            <s:else>
                <%--saveChildrenLandInformation--%>
                <s:submit action="saveSubDividedLandInformation" value="%{getText('next.label')}"
                          onclick="validateFields()"/>

            </s:else>
            <s:submit cssClass="cancel" action="landRegistrationModule" value="%{getText('cancel.label')}"/>
        </div>
        <s:hidden name="alienationType" value="-1"/>
    </s:form>

    <%--  <s:form id="load-form">
        <s:hidden id="alienationMethod" name="alienationType"/>
        <s:hidden id="editMode" name="editMode"/>
    </s:form>--%>
</div>
<s:hidden id="pls_enter_reference_no" value="%{getText('pls_enter_reference_no')}"/>
<s:hidden id="pls_enter_name_of_the_land" value="%{getText('pls_enter_name_of_the_land')}"/>
<s:hidden id="pls_enter_valid_no" value="%{getText('pls_enter_valid_no')}"/>
<s:hidden id="pls_enter_plan_no" value="%{getText('pls_enter_plan_no')}"/>
<s:hidden id="pls_enter_lot_no" value="%{getText('pls_enter_lot_no')}"/>
<s:hidden id="pls_select_gn_division" value="%{getText('pls_select_gn_division')}"/>
<s:hidden id="userRole" name="user.role.id"/>

